
local seen = {}

local save = achievements.GetValue( "Meeting The Locals", "list", "" )
if ( save != "" ) then
	seen = string.Explode( "\n", save )
end

local function Think()
	if ( #seen == 100 ) then hook.Remove( "Think", "Achievements.MeetingTheLocals" ) return end
	local ply = LocalPlayer()
	if ( !ply:IsValid() ) then return end
	local trace = util.QuickTrace( ply:GetShootPos(), ply:GetAimVector() * 8192, ply )
	if ( !trace.Entity || !trace.Entity:IsValid() ) then return end
	if ( !trace.Entity:IsPlayer() ) then return end
	
	local steam = trace.Entity:Name()
	if ( !table.HasValue( seen, steam ) ) then
		seen[ #seen + 1 ] = steam
		achievements.SetValue( "Meeting The Locals", "list", table.concat( seen, "\n" ) )
		
		local total = math.Clamp( #seen, 0, 100 )
		achievements.Update( "Meeting The Locals", total / 100, total .. "/100" )
	end
end
hook.Add( "Think", "Achievements.MeetingTheLocals", Think )

local total = #seen
achievements.Register( "Meeting The Locals", "Spot 100 different players.", "achievements/meetingthelocals", total / 100, total .. "/100" )